import Vue from "vue";
import VueRouter from "vue-router";
// import HomeView from "../views/HomeView.vue";

//引入
import Home from '@/pages/Home'

import Discover from '@/pages/Discover'
// import { count } from "console";
import count from "@/pages/Count"

//把路由注入到所有的子组件
Vue.use(VueRouter);


//定义路由配置  路由配置一般由path 和 component组成
const routes = [
  {
    name:'home',
    path: "/home",
    props:true,
    component:Home,
    children: [
      {
        name:'zujian',
        path:'zujian',
        component:()=>import(/*webpackChunkName:zujian */'@/pages/Home/zujian')

      },
      {
        name:'zujian1',
        path:'zujian1',
        component:()=>import(/*webpackChunkName:zujian1 */'@/pages/Home/zujian1')

      },
    ]
  },
  {
    path:"/discover" , //路径不区分大小写
    component:Discover,

    //重定向
    redirect: '/discover/top',

    //二级路径
    //children属性和routes属性一样  二级路由不要最前面不要带斜杠
    children:[
      {
        name:'top',
        path:'top',
        component:()=>import(/*webpackChunkName:top */'@/pages/Discover/Top')
      },
      {
        name:'dj',
        path:'dj',
        component:()=>import(/*webpackChunkName:dj */'@/pages/Discover/Dj')  
      }
    ]
  },
  {
    path:'/friend',
    //路由赖加载  按需加载
    //将这段代码进行分割  加快首屏的渲染速度
    component:()=>import(/*webpackChunkName:friend */'@/pages/Friend')
  },
  {
    path:'/goods',
    component:()=>import(/*webpackChunkName:goods */'@/pages/Goods')
  },
  
    {
      path:'/detal/:id',
      component:()=>import(/*webpackChunkName:goods */'@/pages/Detal')
    },
    {
  
      path:'/count',
      component:()=>import(/*webpackChunkName:count */'@/pages/Count')
    },
    {
      path:'/',
      redirect:'/gouwuche' 
    },
    {
      path:'/gouwuche',
      component:()=>import(/*webpackChunkName:gouwuche */'@/pages/Gouwuche')
    },
    {
      path:'/axios',
      component:()=>import(/*webpackChunkName:axios */'@/pages/axios')
    },
  
]

// 导出
export default new VueRouter({
  // mode:'history',
  routes
})